package com.app.util;

import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * 分页返回数据
 */
@Data
public class PageResult<T> implements Serializable {
    private Long total;//数据总数
    private List<T> data; //数据
    private Integer code;//返回状态码

    public static PageResult success(Long total, List list) {
        PageResult pageResult = new PageResult();
        pageResult.data = list;
        pageResult.total = total;
        pageResult.code = 200;
        return pageResult;
    }

    public static PageResult fail() {
        PageResult pageResult = new PageResult();
        pageResult.data = null;
        pageResult.code = 500;
        return pageResult;
    }
}
